package com.sicheng.lc.周赛.分类.哈西表or计数or滑动窗口or双指针.计数;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/14 22:32
 */
public class 判断一个数的数字计数是否等于数位的值 {
    //https://leetcode.cn/problems/check-if-number-has-equal-digit-count-and-digit-value/
    public boolean digitCount(String num) {
        int[] counts = new int[10];
        for (int i = 0; i < num.length(); i++) {
            counts[num.charAt(i) - '0']++;
        }
        for (int i = 0; i < num.length(); i++) {
            if (counts[i] != num.charAt(i) - '0') {
                return false;
            }
        }
        return true;

    }
}
